{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9eac6df3-2da9-456b-9a33-757f63a68e0b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-27T12:45:52.032012400Z",
     "start_time": "2024-03-27T12:45:50.463375600Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import warnings\n",
    "\n",
    "from matplotlib.ticker import PercentFormatter\n",
    "\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "%matplotlib inline\n",
    "\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']\n",
    "plt.rcParams['axes.unicode_minus'] = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "5a9c3c7c-91b7-45c5-a116-cc6380974484",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-03-26T14:25:43.938374100Z",
     "start_time": "2024-03-26T14:25:43.884918500Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "       sku_ID  type    brand_ID attribute1 attribute2 activate_date  \\\n0  a234e08c57     1  c3ab4bf4d9        3.0       60.0           NaN   \n1  6449e1fd87     1  1d8b4b4c63        2.0       50.0           NaN   \n2  09b70fcd83     2  eb7d2a675a        3.0       70.0           NaN   \n3  acad9fed04     2  9b0d3a5fc6        3.0       70.0           NaN   \n4  2fa77e3b4d     2  b681299668          -          -           NaN   \n\n  deactivate_date  \n0             NaN  \n1             NaN  \n2             NaN  \n3             NaN  \n4             NaN  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sku_ID</th>\n      <th>type</th>\n      <th>brand_ID</th>\n      <th>attribute1</th>\n      <th>attribute2</th>\n      <th>activate_date</th>\n      <th>deactivate_date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>a234e08c57</td>\n      <td>1</td>\n      <td>c3ab4bf4d9</td>\n      <td>3.0</td>\n      <td>60.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>6449e1fd87</td>\n      <td>1</td>\n      <td>1d8b4b4c63</td>\n      <td>2.0</td>\n      <td>50.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>09b70fcd83</td>\n      <td>2</td>\n      <td>eb7d2a675a</td>\n      <td>3.0</td>\n      <td>70.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>acad9fed04</td>\n      <td>2</td>\n      <td>9b0d3a5fc6</td>\n      <td>3.0</td>\n      <td>70.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2fa77e3b4d</td>\n      <td>2</td>\n      <td>b681299668</td>\n      <td>-</td>\n      <td>-</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sku = pd.read_csv('./JD_data/JD_sku_data.csv')\n",
    "sku.head()"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sku_ID 缺失个数： 0 \t占比为： 0.0 %\n",
      "type 缺失个数： 0 \t占比为： 0.0 %\n",
      "brand_ID 缺失个数： 0 \t占比为： 0.0 %\n",
      "attribute1 缺失个数： 15961 \t占比为： 50.08472448851512 %\n",
      "attribute2 缺失个数： 17319 \t占比为： 54.346052466424 %\n"
     ]
    }
   ],
   "source": [
    "sku['attribute1'] = sku['attribute1'].replace('-', np.nan)\n",
    "sku['attribute2'] = sku['attribute2'].replace('-', np.nan)\n",
    "for column in sku.columns:\n",
    "    df = sku[sku[column].isnull()]\n",
    "    print(column, '缺失个数：', len(df), '\\t占比为：', len(df) / len(sku) * 100, '%')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-26T14:26:23.768920200Z",
     "start_time": "2024-03-26T14:26:23.727314100Z"
    }
   },
   "id": "3cb90e32a8f3f1b7",
   "execution_count": 55
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# 删除activate_date和deactivate_date，这两个属性与最终结果关系不大，而且缺失值过多\n",
    "sku.drop(columns=['activate_date', 'deactivate_date'], inplace=True)\n",
    "sku.to_csv('./preprocess_data/JD_sku_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-26T14:25:53.622314700Z",
     "start_time": "2024-03-26T14:25:53.542713Z"
    }
   },
   "id": "4f25bfc9bfdc9d1d",
   "execution_count": 53
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           user_ID  user_level first_order_month  plus gender    age  \\\n0       000089d6a6           1           2017-08     0      F  26-35   \n1       0000babd1f           1           2018-03     0      U      U   \n2       0000bc018b           3           2016-06     0      F   >=56   \n3       0000d0e5ab           3           2014-06     0      M  26-35   \n4       0000dce472           3           2012-08     1      U      U   \n...            ...         ...               ...   ...    ...    ...   \n457293  ffff38690b           1           2018-03     0      U      U   \n457294  ffffa1a495           4           2011-09     1      M  26-35   \n457295  ffffb20ef7           3           2017-11     0      M  36-45   \n457296  ffffc45330           1           2016-04     0      F  26-35   \n457297  ffffe74cfb           1           2017-10     0      M  26-35   \n\n       marital_status  education  city_level  purchase_power  \n0                   S          3           4               3  \n1                   U         -1          -1              -1  \n2                   M          3           2               3  \n3                   M          3           2               2  \n4                   U         -1          -1              -1  \n...               ...        ...         ...             ...  \n457293              U         -1          -1              -1  \n457294              S          3           1               2  \n457295              M          2           4               2  \n457296              M         -1          -1              -1  \n457297              M         -1           3               3  \n\n[457298 rows x 10 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>first_order_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>2017-08</td>\n      <td>0</td>\n      <td>F</td>\n      <td>26-35</td>\n      <td>S</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0000babd1f</td>\n      <td>1</td>\n      <td>2018-03</td>\n      <td>0</td>\n      <td>U</td>\n      <td>U</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000bc018b</td>\n      <td>3</td>\n      <td>2016-06</td>\n      <td>0</td>\n      <td>F</td>\n      <td>&gt;=56</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0000d0e5ab</td>\n      <td>3</td>\n      <td>2014-06</td>\n      <td>0</td>\n      <td>M</td>\n      <td>26-35</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0000dce472</td>\n      <td>3</td>\n      <td>2012-08</td>\n      <td>1</td>\n      <td>U</td>\n      <td>U</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>457293</th>\n      <td>ffff38690b</td>\n      <td>1</td>\n      <td>2018-03</td>\n      <td>0</td>\n      <td>U</td>\n      <td>U</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>457294</th>\n      <td>ffffa1a495</td>\n      <td>4</td>\n      <td>2011-09</td>\n      <td>1</td>\n      <td>M</td>\n      <td>26-35</td>\n      <td>S</td>\n      <td>3</td>\n      <td>1</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>457295</th>\n      <td>ffffb20ef7</td>\n      <td>3</td>\n      <td>2017-11</td>\n      <td>0</td>\n      <td>M</td>\n      <td>36-45</td>\n      <td>M</td>\n      <td>2</td>\n      <td>4</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>457296</th>\n      <td>ffffc45330</td>\n      <td>1</td>\n      <td>2016-04</td>\n      <td>0</td>\n      <td>F</td>\n      <td>26-35</td>\n      <td>M</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>457297</th>\n      <td>ffffe74cfb</td>\n      <td>1</td>\n      <td>2017-10</td>\n      <td>0</td>\n      <td>M</td>\n      <td>26-35</td>\n      <td>M</td>\n      <td>-1</td>\n      <td>3</td>\n      <td>3</td>\n    </tr>\n  </tbody>\n</table>\n<p>457298 rows × 10 columns</p>\n</div>"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user = pd.read_csv('./JD_data/JD_user_data.csv')\n",
    "user"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:43:00.126848400Z",
     "start_time": "2024-03-27T01:42:59.633083100Z"
    }
   },
   "id": "ae068b91851d7032",
   "execution_count": 18
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "user_ID              457298\nuser_level                7\nfirst_order_month       169\nplus                      2\ngender                    3\nage                       7\nmarital_status            3\neducation                 5\ncity_level                6\npurchase_power            6\ndtype: int64"
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-26T14:27:53.030376200Z",
     "start_time": "2024-03-26T14:27:52.799363900Z"
    }
   },
   "id": "14e62f3745a5ca9d",
   "execution_count": 59
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "457298"
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(user)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-26T14:28:32.097738500Z",
     "start_time": "2024-03-26T14:28:32.059521600Z"
    }
   },
   "id": "f294832f8bd1fa5f",
   "execution_count": 60
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "0         2017-08\n1         2018-03\n2         2016-06\n3         2014-06\n4         2012-08\n           ...   \n457293    2018-03\n457294    2011-09\n457295    2017-11\n457296    2016-04\n457297    2017-10\nName: first_order_month, Length: 457298, dtype: object"
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user['first_order_month']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:22:13.325194600Z",
     "start_time": "2024-03-27T01:22:13.278198700Z"
    }
   },
   "id": "ea0e89be523bd25c",
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus gender    age marital_status  \\\n0  000089d6a6           1           7     0      F  26-35              S   \n1  0000babd1f           1           0     0      U      U              U   \n2  0000bc018b           3          21     0      F   >=56              M   \n3  0000d0e5ab           3          45     0      M  26-35              M   \n4  0000dce472           3          67     1      U      U              U   \n\n   education  city_level  purchase_power  \n0          3           4               3  \n1         -1          -1              -1  \n2          3           2               3  \n3          3           2               2  \n4         -1          -1              -1  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>F</td>\n      <td>26-35</td>\n      <td>S</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0000babd1f</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>U</td>\n      <td>U</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000bc018b</td>\n      <td>3</td>\n      <td>21</td>\n      <td>0</td>\n      <td>F</td>\n      <td>&gt;=56</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0000d0e5ab</td>\n      <td>3</td>\n      <td>45</td>\n      <td>0</td>\n      <td>M</td>\n      <td>26-35</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0000dce472</td>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>U</td>\n      <td>U</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "end_time = pd.to_datetime('2018-03')\n",
    "user['first_order_month'] = pd.to_datetime(user['first_order_month'], format='%Y-%m')\n",
    "user['first_order_month'] = (end_time.year - user['first_order_month'].dt.year) * 12 + (\n",
    "        end_time.month - user['first_order_month'].dt.month)\n",
    "user.rename(columns={'first_order_month': 'user_month'}, inplace=True)\n",
    "user.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:43:07.844132Z",
     "start_time": "2024-03-27T01:43:07.697431200Z"
    }
   },
   "id": "7f47d098f61a6ac5",
   "execution_count": 19
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus gender  age marital_status  \\\n0  000089d6a6           1           7     0      F    3              S   \n1  0000babd1f           1           0     0      U   -1              U   \n2  0000bc018b           3          21     0      F    6              M   \n3  0000d0e5ab           3          45     0      M    3              M   \n4  0000dce472           3          67     1      U   -1              U   \n\n   education  city_level  purchase_power  \n0          3           4               3  \n1         -1          -1              -1  \n2          3           2               3  \n3          3           2               2  \n4         -1          -1              -1  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>F</td>\n      <td>3</td>\n      <td>S</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0000babd1f</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000bc018b</td>\n      <td>3</td>\n      <td>21</td>\n      <td>0</td>\n      <td>F</td>\n      <td>6</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0000d0e5ab</td>\n      <td>3</td>\n      <td>45</td>\n      <td>0</td>\n      <td>M</td>\n      <td>3</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0000dce472</td>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def age_transform(age):\n",
    "    if age == '<=15':\n",
    "        age = 1\n",
    "    elif age == '16-25':\n",
    "        age = 2\n",
    "    elif age == '26-35':\n",
    "        age = 3\n",
    "    elif age == '36-45':\n",
    "        age = 4\n",
    "    elif age == '46-55':\n",
    "        age = 5\n",
    "    elif age == '>=56':\n",
    "        age = 6\n",
    "    else:\n",
    "        age = -1\n",
    "    return age\n",
    "user['age'] = user['age'].apply(age_transform)\n",
    "user.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:43:11.377331200Z",
     "start_time": "2024-03-27T01:43:11.174481Z"
    }
   },
   "id": "d3f372bd88934856",
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus gender  age  marital_status  \\\n0  000089d6a6           1           7     0      F    3               1   \n1  0000babd1f           1           0     0      U   -1              -1   \n2  0000bc018b           3          21     0      F    6               2   \n3  0000d0e5ab           3          45     0      M    3               2   \n4  0000dce472           3          67     1      U   -1              -1   \n\n   education  city_level  purchase_power  \n0          3           4               3  \n1         -1          -1              -1  \n2          3           2               3  \n3          3           2               2  \n4         -1          -1              -1  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>F</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0000babd1f</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000bc018b</td>\n      <td>3</td>\n      <td>21</td>\n      <td>0</td>\n      <td>F</td>\n      <td>6</td>\n      <td>2</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0000d0e5ab</td>\n      <td>3</td>\n      <td>45</td>\n      <td>0</td>\n      <td>M</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n      <td>2</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0000dce472</td>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>U</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def marital_transform(marital):\n",
    "    if marital == 'S':\n",
    "        marital = 1\n",
    "    elif marital == 'M':\n",
    "        marital = 2\n",
    "    else:\n",
    "        marital = -1\n",
    "    return marital\n",
    "user['marital_status'] = user['marital_status'].apply(marital_transform)\n",
    "user.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:45:17.487007100Z",
     "start_time": "2024-03-27T01:45:17.314063300Z"
    }
   },
   "id": "3ff3699cafd5f5e3",
   "execution_count": 21
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      user_ID  user_level  user_month  plus  gender  age  marital_status  \\\n0  000089d6a6           1           7     0       2    3               1   \n1  0000babd1f           1           0     0      -1   -1              -1   \n2  0000bc018b           3          21     0       2    6               2   \n3  0000d0e5ab           3          45     0       1    3               2   \n4  0000dce472           3          67     1      -1   -1              -1   \n\n   education  city_level  purchase_power  \n0          3           4               3  \n1         -1          -1              -1  \n2          3           2               3  \n3          3           2               2  \n4         -1          -1              -1  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>user_ID</th>\n      <th>user_level</th>\n      <th>user_month</th>\n      <th>plus</th>\n      <th>gender</th>\n      <th>age</th>\n      <th>marital_status</th>\n      <th>education</th>\n      <th>city_level</th>\n      <th>purchase_power</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>000089d6a6</td>\n      <td>1</td>\n      <td>7</td>\n      <td>0</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0000babd1f</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000bc018b</td>\n      <td>3</td>\n      <td>21</td>\n      <td>0</td>\n      <td>2</td>\n      <td>6</td>\n      <td>2</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0000d0e5ab</td>\n      <td>3</td>\n      <td>45</td>\n      <td>0</td>\n      <td>1</td>\n      <td>3</td>\n      <td>2</td>\n      <td>3</td>\n      <td>2</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0000dce472</td>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n      <td>-1</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def gender_transform(gender):\n",
    "    if gender == 'M':\n",
    "        gender = 1\n",
    "    elif gender == 'F':\n",
    "        gender = 2\n",
    "    else:\n",
    "        gender = -1\n",
    "    return gender\n",
    "user['gender'] = user['gender'].apply(gender_transform)\n",
    "user.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:46:17.913412900Z",
     "start_time": "2024-03-27T01:46:17.719907500Z"
    }
   },
   "id": "e5c223de1073691a",
   "execution_count": 22
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "user.to_csv('./preprocess_data/JD_user_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T01:46:49.830666300Z",
     "start_time": "2024-03-27T01:46:48.684016300Z"
    }
   },
   "id": "5b26799524286cb9",
   "execution_count": 23
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "       sku_ID     user_ID         request_time channel\n0  a234e08c57  4c3d6d10c2  2018-03-01 23:57:53  wechat\n1  6449e1fd87           -  2018-03-01 16:13:48  wechat\n2  09b70fcd83  2791ec4485  2018-03-01 22:10:51  wechat\n3  09b70fcd83  eb0718c1c9  2018-03-01 16:34:08  wechat\n4  09b70fcd83  59f84cf342  2018-03-01 22:20:35  wechat",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sku_ID</th>\n      <th>user_ID</th>\n      <th>request_time</th>\n      <th>channel</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>a234e08c57</td>\n      <td>4c3d6d10c2</td>\n      <td>2018-03-01 23:57:53</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>6449e1fd87</td>\n      <td>-</td>\n      <td>2018-03-01 16:13:48</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>09b70fcd83</td>\n      <td>2791ec4485</td>\n      <td>2018-03-01 22:10:51</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>09b70fcd83</td>\n      <td>eb0718c1c9</td>\n      <td>2018-03-01 16:34:08</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>09b70fcd83</td>\n      <td>59f84cf342</td>\n      <td>2018-03-01 22:20:35</td>\n      <td>wechat</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click = pd.read_csv('./JD_data/JD_click_data.csv')\n",
    "click.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T12:51:48.285982800Z",
     "start_time": "2024-03-27T12:51:32.500905300Z"
    }
   },
   "id": "b998d3fad53c31f5",
   "execution_count": 8
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "sku_ID            31867\nuser_ID         2557837\nrequest_time    2403971\nchannel               5\ndtype: int64"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T12:52:22.101273100Z",
     "start_time": "2024-03-27T12:52:10.176588Z"
    }
   },
   "id": "5a5dfce9c7308ba0",
   "execution_count": 9
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "sku_ID          0\nuser_ID         0\nrequest_time    0\nchannel         0\ndtype: int64"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click.isnull().sum()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T12:55:21.948868800Z",
     "start_time": "2024-03-27T12:55:21.846012800Z"
    }
   },
   "id": "c47e187a5d43d7e0",
   "execution_count": 10
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "       sku_ID     user_ID         request_time channel\n0  a234e08c57  4c3d6d10c2  2018-03-01 23:57:53  wechat\n1  6449e1fd87         NaN  2018-03-01 16:13:48  wechat\n2  09b70fcd83  2791ec4485  2018-03-01 22:10:51  wechat\n3  09b70fcd83  eb0718c1c9  2018-03-01 16:34:08  wechat\n4  09b70fcd83  59f84cf342  2018-03-01 22:20:35  wechat",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sku_ID</th>\n      <th>user_ID</th>\n      <th>request_time</th>\n      <th>channel</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>a234e08c57</td>\n      <td>4c3d6d10c2</td>\n      <td>2018-03-01 23:57:53</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>6449e1fd87</td>\n      <td>NaN</td>\n      <td>2018-03-01 16:13:48</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>09b70fcd83</td>\n      <td>2791ec4485</td>\n      <td>2018-03-01 22:10:51</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>09b70fcd83</td>\n      <td>eb0718c1c9</td>\n      <td>2018-03-01 16:34:08</td>\n      <td>wechat</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>09b70fcd83</td>\n      <td>59f84cf342</td>\n      <td>2018-03-01 22:20:35</td>\n      <td>wechat</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click['user_ID'] = click['user_ID'].replace('-', np.nan)\n",
    "click.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T12:55:25.772357400Z",
     "start_time": "2024-03-27T12:55:24.315163100Z"
    }
   },
   "id": "c3bac3bd50103038",
   "execution_count": 11
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "sku_ID                0\nuser_ID         2308420\nrequest_time          0\nchannel               0\ndtype: int64"
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click.isnull().sum()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T12:55:30.977942700Z",
     "start_time": "2024-03-27T12:55:28.623627800Z"
    }
   },
   "id": "e9815774eae420f3",
   "execution_count": 12
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "2557836"
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click['user_ID'].nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T12:56:21.383622300Z",
     "start_time": "2024-03-27T12:56:17.860408Z"
    }
   },
   "id": "237a2dcabe1f5f5b",
   "execution_count": 14
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "0           False\n1            True\n2           False\n3           False\n4           False\n            ...  \n20214510     True\n20214511     True\n20214512     True\n20214513     True\n20214514     True\nName: user_ID, Length: 20214515, dtype: bool"
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click['user_ID'].isnull()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:02:59.394476600Z",
     "start_time": "2024-03-27T13:02:59.375382100Z"
    }
   },
   "id": "7ac9f4edaa96aa83",
   "execution_count": 19
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "20214515"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(click)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:05:22.643017600Z",
     "start_time": "2024-03-27T13:05:22.611100200Z"
    }
   },
   "id": "bc88509ee1ce602",
   "execution_count": 21
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "click.drop(click[click['user_ID'].isnull()].index, inplace=True)\n",
    "# click[click['user_ID'].isnull()].index"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:05:42.618864700Z",
     "start_time": "2024-03-27T13:05:41.176738800Z"
    }
   },
   "id": "cef1b4e2c96be411",
   "execution_count": 22
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "17906095"
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(click)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:05:52.494828900Z",
     "start_time": "2024-03-27T13:05:52.465128200Z"
    }
   },
   "id": "79f2146ad38ed259",
   "execution_count": 23
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "sku_ID            27330\nuser_ID         2557836\nrequest_time    2376076\nchannel               5\ndtype: int64"
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "click.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:06:25.044815500Z",
     "start_time": "2024-03-27T13:06:13.947464800Z"
    }
   },
   "id": "a3bddca2c8ab806f",
   "execution_count": 24
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "click.to_csv('./preprocess_data/JD_click_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:09:33.973660600Z",
     "start_time": "2024-03-27T13:08:58.893251300Z"
    }
   },
   "id": "c8269b64a0657538",
   "execution_count": 25
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "     order_ID     user_ID      sku_ID  order_date             order_time  \\\n0  d0cf5cc6db  0abe9ef2ce  581d5b54c1  2018-03-01  2018-03-01 17:14:25.0   \n1  7444318d01  33a9e56257  067b673f2b  2018-03-01  2018-03-01 11:10:40.0   \n2  f973b01694  4ea3cf408f  623d0a582a  2018-03-01  2018-03-01 09:13:26.0   \n3  8c1cec8d4b  b87cb736cb  fc5289b139  2018-03-01  2018-03-01 21:29:50.0   \n4  d43a33c38a  4829223b6f  623d0a582a  2018-03-01  2018-03-01 19:13:37.0   \n\n   quantity  type promise  original_unit_price  final_unit_price  \\\n0         1     2       -                 89.0              79.0   \n1         1     1       2                 99.9              53.9   \n2         1     1       2                 78.0              58.5   \n3         1     1       2                 61.0              35.0   \n4         1     1       1                 78.0              53.0   \n\n   direct_discount_per_unit  quantity_discount_per_unit  \\\n0                       0.0                        10.0   \n1                       5.0                        41.0   \n2                      19.5                         0.0   \n3                       0.0                        26.0   \n4                      19.0                         0.0   \n\n   bundle_discount_per_unit  coupon_discount_per_unit  gift_item  dc_ori  \\\n0                       0.0                       0.0          0       4   \n1                       0.0                       0.0          0      28   \n2                       0.0                       0.0          0      28   \n3                       0.0                       0.0          0       4   \n4                       0.0                       6.0          0       3   \n\n   dc_des  \n0      28  \n1      28  \n2      28  \n3      28  \n4      16  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>order_ID</th>\n      <th>user_ID</th>\n      <th>sku_ID</th>\n      <th>order_date</th>\n      <th>order_time</th>\n      <th>quantity</th>\n      <th>type</th>\n      <th>promise</th>\n      <th>original_unit_price</th>\n      <th>final_unit_price</th>\n      <th>direct_discount_per_unit</th>\n      <th>quantity_discount_per_unit</th>\n      <th>bundle_discount_per_unit</th>\n      <th>coupon_discount_per_unit</th>\n      <th>gift_item</th>\n      <th>dc_ori</th>\n      <th>dc_des</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>d0cf5cc6db</td>\n      <td>0abe9ef2ce</td>\n      <td>581d5b54c1</td>\n      <td>2018-03-01</td>\n      <td>2018-03-01 17:14:25.0</td>\n      <td>1</td>\n      <td>2</td>\n      <td>-</td>\n      <td>89.0</td>\n      <td>79.0</td>\n      <td>0.0</td>\n      <td>10.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>4</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>7444318d01</td>\n      <td>33a9e56257</td>\n      <td>067b673f2b</td>\n      <td>2018-03-01</td>\n      <td>2018-03-01 11:10:40.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>99.9</td>\n      <td>53.9</td>\n      <td>5.0</td>\n      <td>41.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>28</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>f973b01694</td>\n      <td>4ea3cf408f</td>\n      <td>623d0a582a</td>\n      <td>2018-03-01</td>\n      <td>2018-03-01 09:13:26.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>78.0</td>\n      <td>58.5</td>\n      <td>19.5</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>28</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>8c1cec8d4b</td>\n      <td>b87cb736cb</td>\n      <td>fc5289b139</td>\n      <td>2018-03-01</td>\n      <td>2018-03-01 21:29:50.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>2</td>\n      <td>61.0</td>\n      <td>35.0</td>\n      <td>0.0</td>\n      <td>26.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>4</td>\n      <td>28</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>d43a33c38a</td>\n      <td>4829223b6f</td>\n      <td>623d0a582a</td>\n      <td>2018-03-01</td>\n      <td>2018-03-01 19:13:37.0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>78.0</td>\n      <td>53.0</td>\n      <td>19.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>6.0</td>\n      <td>0</td>\n      <td>3</td>\n      <td>16</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "order = pd.read_csv('./JD_data/JD_order_data.csv')\n",
    "order.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:12:45.793645200Z",
     "start_time": "2024-03-27T13:12:44.539819600Z"
    }
   },
   "id": "34c7c05a244610d6",
   "execution_count": 26
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "order.drop(columns='order_date', inplace=True)\n",
    "order.to_csv('./preprocess_data/JD_order_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:17:23.163154Z",
     "start_time": "2024-03-27T13:17:19.725810700Z"
    }
   },
   "id": "7b200b53c3050a13",
   "execution_count": 27
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "   package_ID    order_ID  type        ship_out_time     arr_station_time  \\\n0  dc3d6d2258  dc3d6d2258     1  2018-03-01 08:00:00  2018-03-01 15:00:00   \n1  19802a570c  19802a570c     1  2018-03-01 10:00:00  2018-03-01 15:00:00   \n2  e22627af66  e22627af66     1  2018-03-01 11:00:00  2018-03-01 15:00:00   \n3  50d11a586d  50d11a586d     1  2018-03-01 10:00:00  2018-03-01 16:00:00   \n4  a3bfe38bf4  a3bfe38bf4     1  2018-03-01 11:00:00  2018-03-01 16:00:00   \n\n              arr_time  \n0  2018-03-01 18:00:00  \n1  2018-03-01 17:00:00  \n2  2018-03-01 17:00:00  \n3  2018-03-01 19:00:00  \n4  2018-03-01 17:00:00  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>package_ID</th>\n      <th>order_ID</th>\n      <th>type</th>\n      <th>ship_out_time</th>\n      <th>arr_station_time</th>\n      <th>arr_time</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>dc3d6d2258</td>\n      <td>dc3d6d2258</td>\n      <td>1</td>\n      <td>2018-03-01 08:00:00</td>\n      <td>2018-03-01 15:00:00</td>\n      <td>2018-03-01 18:00:00</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>19802a570c</td>\n      <td>19802a570c</td>\n      <td>1</td>\n      <td>2018-03-01 10:00:00</td>\n      <td>2018-03-01 15:00:00</td>\n      <td>2018-03-01 17:00:00</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>e22627af66</td>\n      <td>e22627af66</td>\n      <td>1</td>\n      <td>2018-03-01 11:00:00</td>\n      <td>2018-03-01 15:00:00</td>\n      <td>2018-03-01 17:00:00</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>50d11a586d</td>\n      <td>50d11a586d</td>\n      <td>1</td>\n      <td>2018-03-01 10:00:00</td>\n      <td>2018-03-01 16:00:00</td>\n      <td>2018-03-01 19:00:00</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>a3bfe38bf4</td>\n      <td>a3bfe38bf4</td>\n      <td>1</td>\n      <td>2018-03-01 11:00:00</td>\n      <td>2018-03-01 16:00:00</td>\n      <td>2018-03-01 17:00:00</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delivery = pd.read_csv('./JD_data/JD_delivery_data.csv')\n",
    "delivery.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:29:55.722071300Z",
     "start_time": "2024-03-27T13:29:55.239568500Z"
    }
   },
   "id": "3f03dd8040719521",
   "execution_count": 42
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "        package_ID    order_ID  type       ship_out_time arr_station_time  \\\n0       dc3d6d2258  dc3d6d2258     1 2018-03-01 08:00:00  0 days 07:00:00   \n1       19802a570c  19802a570c     1 2018-03-01 10:00:00  0 days 05:00:00   \n2       e22627af66  e22627af66     1 2018-03-01 11:00:00  0 days 04:00:00   \n3       50d11a586d  50d11a586d     1 2018-03-01 10:00:00  0 days 06:00:00   \n4       a3bfe38bf4  a3bfe38bf4     1 2018-03-01 11:00:00  0 days 05:00:00   \n...            ...         ...   ...                 ...              ...   \n293224  6130c1b7d1  6130c1b7d1     1 2018-04-01 09:00:00  4 days 09:00:00   \n293225  77df47b5cb  ffe59a02ed     0 2018-03-30 11:00:00  6 days 19:00:00   \n293226  cb319102f1  cb319102f1     1 2018-04-01 10:00:00  6 days 01:00:00   \n293227  0fe3bbcfd8  0fe3bbcfd8     1 2018-03-31 13:00:00  4 days 09:00:00   \n293228  d22fa05841  d22fa05841     1 2018-03-25 09:00:00  1 days 00:00:00   \n\n               arr_time  \n0       0 days 10:00:00  \n1       0 days 07:00:00  \n2       0 days 06:00:00  \n3       0 days 09:00:00  \n4       0 days 06:00:00  \n...                 ...  \n293224  6 days 01:00:00  \n293225  8 days 04:00:00  \n293226  6 days 05:00:00  \n293227  6 days 22:00:00  \n293228 13 days 05:00:00  \n\n[293229 rows x 6 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>package_ID</th>\n      <th>order_ID</th>\n      <th>type</th>\n      <th>ship_out_time</th>\n      <th>arr_station_time</th>\n      <th>arr_time</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>dc3d6d2258</td>\n      <td>dc3d6d2258</td>\n      <td>1</td>\n      <td>2018-03-01 08:00:00</td>\n      <td>0 days 07:00:00</td>\n      <td>0 days 10:00:00</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>19802a570c</td>\n      <td>19802a570c</td>\n      <td>1</td>\n      <td>2018-03-01 10:00:00</td>\n      <td>0 days 05:00:00</td>\n      <td>0 days 07:00:00</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>e22627af66</td>\n      <td>e22627af66</td>\n      <td>1</td>\n      <td>2018-03-01 11:00:00</td>\n      <td>0 days 04:00:00</td>\n      <td>0 days 06:00:00</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>50d11a586d</td>\n      <td>50d11a586d</td>\n      <td>1</td>\n      <td>2018-03-01 10:00:00</td>\n      <td>0 days 06:00:00</td>\n      <td>0 days 09:00:00</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>a3bfe38bf4</td>\n      <td>a3bfe38bf4</td>\n      <td>1</td>\n      <td>2018-03-01 11:00:00</td>\n      <td>0 days 05:00:00</td>\n      <td>0 days 06:00:00</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>293224</th>\n      <td>6130c1b7d1</td>\n      <td>6130c1b7d1</td>\n      <td>1</td>\n      <td>2018-04-01 09:00:00</td>\n      <td>4 days 09:00:00</td>\n      <td>6 days 01:00:00</td>\n    </tr>\n    <tr>\n      <th>293225</th>\n      <td>77df47b5cb</td>\n      <td>ffe59a02ed</td>\n      <td>0</td>\n      <td>2018-03-30 11:00:00</td>\n      <td>6 days 19:00:00</td>\n      <td>8 days 04:00:00</td>\n    </tr>\n    <tr>\n      <th>293226</th>\n      <td>cb319102f1</td>\n      <td>cb319102f1</td>\n      <td>1</td>\n      <td>2018-04-01 10:00:00</td>\n      <td>6 days 01:00:00</td>\n      <td>6 days 05:00:00</td>\n    </tr>\n    <tr>\n      <th>293227</th>\n      <td>0fe3bbcfd8</td>\n      <td>0fe3bbcfd8</td>\n      <td>1</td>\n      <td>2018-03-31 13:00:00</td>\n      <td>4 days 09:00:00</td>\n      <td>6 days 22:00:00</td>\n    </tr>\n    <tr>\n      <th>293228</th>\n      <td>d22fa05841</td>\n      <td>d22fa05841</td>\n      <td>1</td>\n      <td>2018-03-25 09:00:00</td>\n      <td>1 days 00:00:00</td>\n      <td>13 days 05:00:00</td>\n    </tr>\n  </tbody>\n</table>\n<p>293229 rows × 6 columns</p>\n</div>"
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delivery['ship_out_time'] = pd.to_datetime(delivery['ship_out_time'])\n",
    "delivery['arr_station_time'] = pd.to_datetime(delivery['arr_station_time'])\n",
    "delivery['arr_time'] = pd.to_datetime(delivery['arr_time'])\n",
    "delivery['arr_station_time'] = delivery['arr_station_time'] - delivery['ship_out_time']\n",
    "delivery['arr_time'] = delivery['arr_time'] - delivery['ship_out_time']\n",
    "delivery"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:30:34.474690300Z",
     "start_time": "2024-03-27T13:30:34.308927600Z"
    }
   },
   "id": "b9b984a1e2623f0a",
   "execution_count": 43
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "        package_ID    order_ID  type       ship_out_time  arr_station_time  \\\n0       dc3d6d2258  dc3d6d2258     1 2018-03-01 08:00:00               7.0   \n1       19802a570c  19802a570c     1 2018-03-01 10:00:00               5.0   \n2       e22627af66  e22627af66     1 2018-03-01 11:00:00               4.0   \n3       50d11a586d  50d11a586d     1 2018-03-01 10:00:00               6.0   \n4       a3bfe38bf4  a3bfe38bf4     1 2018-03-01 11:00:00               5.0   \n...            ...         ...   ...                 ...               ...   \n293224  6130c1b7d1  6130c1b7d1     1 2018-04-01 09:00:00               9.0   \n293225  77df47b5cb  ffe59a02ed     0 2018-03-30 11:00:00              19.0   \n293226  cb319102f1  cb319102f1     1 2018-04-01 10:00:00               1.0   \n293227  0fe3bbcfd8  0fe3bbcfd8     1 2018-03-31 13:00:00               9.0   \n293228  d22fa05841  d22fa05841     1 2018-03-25 09:00:00               0.0   \n\n        arr_time  \n0           10.0  \n1            7.0  \n2            6.0  \n3            9.0  \n4            6.0  \n...          ...  \n293224       1.0  \n293225       4.0  \n293226       5.0  \n293227      22.0  \n293228       5.0  \n\n[293229 rows x 6 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>package_ID</th>\n      <th>order_ID</th>\n      <th>type</th>\n      <th>ship_out_time</th>\n      <th>arr_station_time</th>\n      <th>arr_time</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>dc3d6d2258</td>\n      <td>dc3d6d2258</td>\n      <td>1</td>\n      <td>2018-03-01 08:00:00</td>\n      <td>7.0</td>\n      <td>10.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>19802a570c</td>\n      <td>19802a570c</td>\n      <td>1</td>\n      <td>2018-03-01 10:00:00</td>\n      <td>5.0</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>e22627af66</td>\n      <td>e22627af66</td>\n      <td>1</td>\n      <td>2018-03-01 11:00:00</td>\n      <td>4.0</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>50d11a586d</td>\n      <td>50d11a586d</td>\n      <td>1</td>\n      <td>2018-03-01 10:00:00</td>\n      <td>6.0</td>\n      <td>9.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>a3bfe38bf4</td>\n      <td>a3bfe38bf4</td>\n      <td>1</td>\n      <td>2018-03-01 11:00:00</td>\n      <td>5.0</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>293224</th>\n      <td>6130c1b7d1</td>\n      <td>6130c1b7d1</td>\n      <td>1</td>\n      <td>2018-04-01 09:00:00</td>\n      <td>9.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>293225</th>\n      <td>77df47b5cb</td>\n      <td>ffe59a02ed</td>\n      <td>0</td>\n      <td>2018-03-30 11:00:00</td>\n      <td>19.0</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>293226</th>\n      <td>cb319102f1</td>\n      <td>cb319102f1</td>\n      <td>1</td>\n      <td>2018-04-01 10:00:00</td>\n      <td>1.0</td>\n      <td>5.0</td>\n    </tr>\n    <tr>\n      <th>293227</th>\n      <td>0fe3bbcfd8</td>\n      <td>0fe3bbcfd8</td>\n      <td>1</td>\n      <td>2018-03-31 13:00:00</td>\n      <td>9.0</td>\n      <td>22.0</td>\n    </tr>\n    <tr>\n      <th>293228</th>\n      <td>d22fa05841</td>\n      <td>d22fa05841</td>\n      <td>1</td>\n      <td>2018-03-25 09:00:00</td>\n      <td>0.0</td>\n      <td>5.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>293229 rows × 6 columns</p>\n</div>"
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delivery['arr_station_time'] = delivery['arr_station_time'].map(lambda x: x.seconds/3600)\n",
    "delivery['arr_time'] = delivery['arr_time'].map(lambda x: x.seconds/3600)\n",
    "delivery"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:38:49.637287500Z",
     "start_time": "2024-03-27T13:38:48.345482Z"
    }
   },
   "id": "c7255aba1547b774",
   "execution_count": 56
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "        package_ID    order_ID  type  arr_station_time  arr_time\n0       dc3d6d2258  dc3d6d2258     1               7.0      10.0\n1       19802a570c  19802a570c     1               5.0       7.0\n2       e22627af66  e22627af66     1               4.0       6.0\n3       50d11a586d  50d11a586d     1               6.0       9.0\n4       a3bfe38bf4  a3bfe38bf4     1               5.0       6.0\n...            ...         ...   ...               ...       ...\n293224  6130c1b7d1  6130c1b7d1     1               9.0       1.0\n293225  77df47b5cb  ffe59a02ed     0              19.0       4.0\n293226  cb319102f1  cb319102f1     1               1.0       5.0\n293227  0fe3bbcfd8  0fe3bbcfd8     1               9.0      22.0\n293228  d22fa05841  d22fa05841     1               0.0       5.0\n\n[293229 rows x 5 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>package_ID</th>\n      <th>order_ID</th>\n      <th>type</th>\n      <th>arr_station_time</th>\n      <th>arr_time</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>dc3d6d2258</td>\n      <td>dc3d6d2258</td>\n      <td>1</td>\n      <td>7.0</td>\n      <td>10.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>19802a570c</td>\n      <td>19802a570c</td>\n      <td>1</td>\n      <td>5.0</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>e22627af66</td>\n      <td>e22627af66</td>\n      <td>1</td>\n      <td>4.0</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>50d11a586d</td>\n      <td>50d11a586d</td>\n      <td>1</td>\n      <td>6.0</td>\n      <td>9.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>a3bfe38bf4</td>\n      <td>a3bfe38bf4</td>\n      <td>1</td>\n      <td>5.0</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>293224</th>\n      <td>6130c1b7d1</td>\n      <td>6130c1b7d1</td>\n      <td>1</td>\n      <td>9.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>293225</th>\n      <td>77df47b5cb</td>\n      <td>ffe59a02ed</td>\n      <td>0</td>\n      <td>19.0</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>293226</th>\n      <td>cb319102f1</td>\n      <td>cb319102f1</td>\n      <td>1</td>\n      <td>1.0</td>\n      <td>5.0</td>\n    </tr>\n    <tr>\n      <th>293227</th>\n      <td>0fe3bbcfd8</td>\n      <td>0fe3bbcfd8</td>\n      <td>1</td>\n      <td>9.0</td>\n      <td>22.0</td>\n    </tr>\n    <tr>\n      <th>293228</th>\n      <td>d22fa05841</td>\n      <td>d22fa05841</td>\n      <td>1</td>\n      <td>0.0</td>\n      <td>5.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>293229 rows × 5 columns</p>\n</div>"
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delivery.drop(columns='ship_out_time', inplace=True)\n",
    "delivery"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:39:35.159664300Z",
     "start_time": "2024-03-27T13:39:35.095920Z"
    }
   },
   "id": "14c555273fe369e",
   "execution_count": 57
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "delivery.to_csv('./preprocess_data/JD_delivery_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:39:46.547657500Z",
     "start_time": "2024-03-27T13:39:45.771534800Z"
    }
   },
   "id": "73406ba95bde4ce8",
   "execution_count": 58
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "   dc_ID      sku_ID        date\n0      9  50f6f91962  2018-03-01\n1      9  7f0ddbcdde  2018-03-01\n2      9  8ad5789d74  2018-03-01\n3      9  468d34eda4  2018-03-01\n4      9  460afaddb6  2018-03-01",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>dc_ID</th>\n      <th>sku_ID</th>\n      <th>date</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>9</td>\n      <td>50f6f91962</td>\n      <td>2018-03-01</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>9</td>\n      <td>7f0ddbcdde</td>\n      <td>2018-03-01</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>9</td>\n      <td>8ad5789d74</td>\n      <td>2018-03-01</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>9</td>\n      <td>468d34eda4</td>\n      <td>2018-03-01</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>9</td>\n      <td>460afaddb6</td>\n      <td>2018-03-01</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inventory = pd.read_csv('./JD_data/JD_inventory_data.csv')\n",
    "inventory.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:19:50.482275200Z",
     "start_time": "2024-03-27T13:19:50.401000600Z"
    }
   },
   "id": "5229b6eca441bd7",
   "execution_count": 30
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "dc_ID      56\nsku_ID    390\ndate       31\ndtype: int64"
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inventory.nunique()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:20:09.690934600Z",
     "start_time": "2024-03-27T13:20:09.644849700Z"
    }
   },
   "id": "fc0a9464220771a7",
   "execution_count": 31
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "inventory.to_csv('./preprocess_data/JD_inventory_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:20:47.359420100Z",
     "start_time": "2024-03-27T13:20:47.131664600Z"
    }
   },
   "id": "46ab684379ebf16b",
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "   region_ID  dc_ID\n0          2     57\n1          2     43\n2          2     42\n3          2     66\n4          2     20",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>region_ID</th>\n      <th>dc_ID</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2</td>\n      <td>57</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2</td>\n      <td>43</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2</td>\n      <td>42</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2</td>\n      <td>66</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2</td>\n      <td>20</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "network = pd.read_csv('./JD_data/JD_network_data.csv')\n",
    "network.head()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:21:24.208037500Z",
     "start_time": "2024-03-27T13:21:24.179184800Z"
    }
   },
   "id": "ff421fbf0db8feed",
   "execution_count": 34
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "network.to_csv('./preprocess_data/JD_network_data.csv', index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-27T13:21:43.393688100Z",
     "start_time": "2024-03-27T13:21:43.366100900Z"
    }
   },
   "id": "e64d1109f35cba4c",
   "execution_count": 35
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "9adb34511ad6ec77"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
